package com.example.demo.Controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;


@RequestMapping("/request")
@RestController
public class RequestController {

    @RequestMapping("/hello")
    public String say(){
        return "hello, say World";
    }

    @RequestMapping("/r1")
    public String r1(String name){
        return "接收到参数:"+name;
    }

    @RequestMapping("/r4")
    public String r4(String name, Integer age){
        return "接到参数 name:"+name+", age:"+age;
    }

    @RequestMapping("/r5")
    public String r5(@RequestParam(value = "name",required = false) String userName){
        return "接到参数：name"+userName;
    }

    @RequestMapping("/r6")
    public String r6(String[] array){
        return "接到参数：array:"+ Arrays.toString(array);
    }


    @RequestMapping("/article/{articleId}")
    public String r7(@PathVariable("articleId") Integer articleId){
        return "接到参数，articleId:"+articleId;
    }

    //传递参数：
    @RequestMapping("/r9")
    public String r9(MultipartFile file){
        String originalFilename = file.getOriginalFilename();
        return "接收到文件：文件名称："+originalFilename;
    }



}












